from flask_restful import Api
from flask import jsonify

api = Api()
def init_restful(app):
    api.init_app(app)

def init_error_restful(app):
    @app.errorhandler(403)
    def page_not_arrived(e):
        return jsonify({
            "code": 403,
            "message": "The requested URL was not arrived to be prohibited"
        }), 403

    @app.errorhandler(404)
    def page_not_found(e):
        return jsonify({
            "code": 404,
            "message": "The requested URL was not found on the server"
        }), 404

    @app.errorhandler(500)
    def internal_server_error(e):
        return jsonify({
            "code": 500,
            "message": "The server encountered an internal error"
        }), 500
